package com.design.patterns.list.adapter.objectadapter;

import com.design.patterns.list.adapter.classadapter.Voltage5V;

/**
 * 适配器
 *
 * @author Wangzhiwen
 */
public class VoltageAdapter implements Voltage5V {

    // 对象适配器，把被适配者内置到适配器属性中
    private Voltage220V voltage220V;

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }
    public void setVoltage220V(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    /**
     * 将不适配的接口方法转换成可以使用的接口方法
     */
    @Override
    public int out5V() {
        int out220V = voltage220V.out220V();
        return out220V/44;
    }
}
